<!DOCTYPE HTML>
<html>

	<head>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>富宏堂中医馆
		</title>
		<link href="css/main.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<link href="bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
		<script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
		<script src="js/jquery.SuperSlide.2.1.1.js"></script>
		<script type="text/javascript" src="bootstrap/dist/js/bootstrap.js"></script>
		<script src="js/common.js" type="text/javascript"></script>
		<style type="text/css">
			a {
				text-decoration: none
			}
			
			boby {
				background-color: #EFEFEF
			}
			
			.activity-item-container {
				padding-bottom: 50px;
			}
			
			.content-container {
				margin: 0 auto;
				margin-top: 100px;
				width: 1240px;
				min-height: 100vh;
			}
			
			.item-catalog-container {
				margin-top: 30px;
				margin-bottom: 28px;
				width: 100%;
			}
			
			.item-catalog-container .catalog-item {
				display: inline-block;
			}
			
			.item-container .item-head {
				position: relative;
			}
			
			.item-container .item-head .card {
				padding: 24px;
				height: 300px;
			}
			
			.card {
				padding: 18px;
				background-color: #fff;
				border: .5px solid #eee;
				box-shadow: 0 0 0.5px rgba(0, 0, 0, .2);
			}
			
			.item-container .item-head-img-container {
				padding-left: 0;
				height: 100%;
			}
			
			.item-container .item-head-img {
				height: 100%;
				background-color: #1f86ed;
			}
			
			.activity-item-container .item-head-text .member-offer {
				float: left;
				margin-top: 3px;
				margin-right: 10px;
				height: 21px;
				width: 92px;
				background: url(/images/tag/member-offer.png);
			}
			
			.activity-item-container .item-head .attribute {
				margin-bottom: 0;
			}
			
			.item-container .item-head-text .attribute {
				font-size: 17px;
				line-height: 1.8;
			}
			
			.m-cover {
				background-color: #1f86ed;
				background-size: cover;
				background-position: 50%;
				background-repeat: no-repeat;
			}
			
			.activity-item-container .item-head-btn-container {
				display: -ms-flexbox;
				display: flex;
				-ms-flex-pack: justify;
				justify-content: space-between;
				width: 100%;
				height: 45px;
				margin-top: 50px;
			}
			
			.item-container .item-head-btn-func {
				padding: 7.5px 30px;
				width: 170px;
				font-size: 20px;
			}
			
			.activity-item-container .item-head-btn-container .btn-caption {
				-ms-flex-positive: 1;
				flex-grow: 1;
				-ms-flex-item-align: end;
				align-self: flex-end;
				color: #898989;
			}
			
			.container-fluid {
				padding-right: 15px;
				padding-left: 15px;
				margin-right: auto;
				margin-left: auto;
			}
			
			.row {
				margin-right: -15px;
				margin-left: -15px;
			}
			
			.item-container .item-content {
				margin-top: 20px;
				padding-left: 0;
				padding-right: 0;
				width: 100%;
			}
			
			.card {
				padding: 18px;
				background-color: #fff;
				border: .5px solid #eee;
				box-shadow: 0 0 0.5px rgba(0, 0, 0, .2);
			}
			
			.item-container .item-content .sub-title {
				margin-top: 0;
				margin-bottom: 20px;
				padding-left: 15px;
				height: 36px;
				line-height: 36px;
				font-size: 20px;
				font-weight: 700;
				color: #1f86ed;
				border-left: 10px solid #1f86ed;
			}
			
			.fr-view {
				text-indent: 0;
			}
			
			.activity-item-container .item-body .divider {
				margin-top: 20px;
				margin-bottom: 20px;
				border-bottom: 1px solid #eee;
			}
			a{
			    text-decoration : none
			}
			h1{
			    font-family: inherit;
			    font-weight: 500;
			    line-height: 1.1;
			    color: inherit;
			}
			h2{
				font-weight: bold;
				font-size: 18px;
			}
			.divider2{
				width: 734px;
			    height: auto;
			    overflow: hidden;
			    border-bottom: 1px dashed #b2b2b2;
			    padding: 3px 0px;
			}
			.hos_row9_con2 {
			    width: 732px;
			    height: 100px;
			    overflow: hidden;
			    border: 1px solid #b2b2b2;
			    background-color: #fcfcfc;
			    font-size: 16px;
			}
		</style>
	</head>

	<body style="background-color: #EFEFEF">
		<!--头部-->
		<header>
		    <div class="beijing">
		        <h2><a href="index.html" style="text-decoration : none"><em style="width:120px;"><font color="#CC0000">富宏堂中医馆</font></em></a></h2>
		        <ul>
		            <li>
		                <a class="menu_1 "  href="index.html" >首页</a>
		            </li>
		            <li>
		                <a class="menu_1 " href="hospital.html">分馆介绍<em></em></a>
		            </li>
		            <li>
		                <a class="menu_1 hover" href="doctor.html">预约挂号<em></em></a>
		            </li>
		            <li>
		                <a class="menu_1 " href="tech.html" >人才招聘<em></em></a>
		            </li>
		            <li>
		                <a class="menu_1 " href="javascript:gotoPersoninfo()" >个人中心<em></em></a>
		            </li>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
		        </ul>
		        <div class="clear"></div>       
		    </div>
		    <div class="clear"></div>
		</header>

		<!--主体-->
		<div class="content-container item-container activity-item-container">
			<div class="item-catalog-container">
				<div class="catalog-item">
					<a href="#" style="color: #707070" class="nuxt-link-active">首页</a>
					&gt;
				</div>
				<div class="catalog-item">
					<a href="#" style="color: #707070" class="nuxt-link-active">预约挂号</a>
					&gt;
				</div>
				<div class="catalog-item">
					<a href="javascript:void(0)" style="color: #707070">详情</a>
				</div>
			</div>

			<div class="item-head">
				<div class="clearfix card">
					<div class="col-xs-8 item-head-text">
						<div>
						    <input type="hidden" id="doctorid"/>
						    <em><img id="img1"  style="width: 150px;height: 155px;"></em>
							<h3 class="title" id="doctorname">测试</h3>
							<p class="attribute">
								职称：<span id="title">教授</span>
							</p>
							<p class="attribute">
								坐诊：<span id="hospitalname">江苏 - 南京医馆-三山街</span>
							</p>
						</div>
					</div>
				</div>
			</div>
			<div class="container-fluid item-body">
				<div class="row">
					<div id="leftAlign" class="col-xs-9 item-content">
						<div class="card">
							<h4 class="sub-title" style="color: #C80000;border-left: 10px solid #C80000;">专家擅长</h4>
							<div class="fr-view" id="advantage" style="font-size: 16px;">测试测试测试内容</div>
							<div class="divider"></div>
							<h4 class="sub-title" style="color: #C80000;border-left: 10px solid #C80000;">专家简介</h4>
							<div class="fr-view" id="introduction" style="font-size: 16px;">测试测试测试内容</div>
							<div class="divider"></div>
							<h4 class="sub-title" style="color: #C80000;border-left: 10px solid #C80000;">坐诊时间</h4>
                            <div class="fr-view" id="introduction">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                        <td align='center'>坐诊医馆</td>
                                        <td align='center'>日期</td>
                                        <td align='center'>开始时间</td>
                                        <td align='center'>结束时间</td>
                                        <td align='center'>操作</td>
                                    </thead>
                                    <tbody id="dutyBody">
                                    </tbody>
                                </table>
                            </div>
                            <div class="divider"></div>
                            
                            <h4 class="sub-title" style="color: #C80000;border-left: 10px solid #C80000;">客户评价</h4>
                            <div class="fr-view" id="introduction" >
                                <div class="hos_row9_con2">
									<div style="margin: 5px;">为了最大程度保障顾客康复以及愉悦的就诊体验，我们诚邀您对我们各馆进行点评；为保证评价真实有效，评价要求您是注册用户</div>
									<button class="btn btn-danger" onclick="gotoComment();" style="float: right;margin-right: 5px">我也要评</button>
								</div>
								<div id="commentList">
                                </div>
                            </div>
						</div>
					</div>
				</div>
			</div>
			
			
			<!-- 模态框（Modal） -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h4 class="modal-title" id="myModalLabel">评论</h4>
                        </div>
                        <div class="modal-body">
                             <form role="form">
                                  <div class="form-group">
                                    <label for="name">用户ID</label>
                                    <input type="text" disabled class="form-control" id="userid" autocomplete="off"/>
                                  </div>
                                  <div class="form-group">
                                    <label for="consult">评价内容</label>
                                    <textarea id=content class="form-control" rows="3"></textarea>
                                  </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button id="submitCooper" type="button" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.modal -->
            <script>
                $(function() {
                    $('#myModal').modal('hide');
                    
                    $("#submitCooper").click(function(){
                        var data={"content":$("#content").val(),"doctorid":$("#doctorid").val()
                                ,"createUserid":getCookie("userid")
                        }
                        $.ajax({
                            url:"/message/insert",
                            type:"post",
                            data:JSON.stringify(data),
                            contentType: "application/json; charset=utf-8",
                            success:function(res){
                                alert("提交成功");
                                location.reload();
                            }
                        })
                    })
                });
            </script>
	</body>

</html>
<script type="text/javascript">
	function getQueryStringByName(name) {
		var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
		if(result == null || result.length < 1) {
			return "";
		}
		return result[1];
	}
	
	

	$(document).ready(function() {
		var id = getQueryStringByName("id");
		if(id == null) {
			alert("无数据!");
			return;
		}
		
		$.ajax({
			type: "GET",
			dataType: "json",
			url: '/doctors/info/' + id,
			success: function(res) {
				if(res != null) {
					$("#doctorname").html(res.data.doctorname);
					$("#title").html(res.data.title);
					$("#hospitalname").html(res.data.hospitalname);
					$("#advantage").html(res.data.advantage);
					$("#introduction").html(res.data.introduction);
					$("#img1").attr("src",res.data.img1);
					$("#doctorid").val(res.data.id);
				} else {
					alert("无数据!");
				}
			}
		});
		
		
		$.ajax({
            type: "post",
            data:{'doctorid':id},
            dataType: "json",
            url: '/duty/search',
            success: function(res) {
            	for(let i=0;i<res.rows.length;i++){
	                $("#dutyBody").append(`
	                		<tr>
		                        <td align='center'>${res.rows[i].hospitalname}</td>
		                        <td align='center'>${res.rows[i].dutyDate}</td>
		                        <td align='center'>${res.rows[i].dutyStartTime}</td>
		                        <td align='center'>${res.rows[i].dutyEndTime}</td>
		                        <td align='center'>
		                        <button type="button" class="btn btn-danger" onclick="gotoOrder(${res.rows[i].hospitalid},'${res.rows[i].dutyDate}')">预约挂号</button>
		                        </td>
	                        </tr>`)
            	}
            }
        });
		
		//查询评论列表
		$.ajax({
            type: "post",
            data:{'doctorid':id},
            dataType: "json",
            url: '/message/search',
            success: function(res) {
                for(let i=0;i<res.rows.length;i++){
                   $("#commentList").append(`
               		   <div style="letter-spacing: 0px;line-height: 20px;word-break: break-all;">
                          <h5 class="fl" style="color:#808080;">顾客：<span style="color:#000;">${res.rows[i].createUsername}</span></h5>
                       </div>
                       <div style="letter-spacing: 0px;line-height: 20px;word-break: break-all;">
                           <h5 class="fl" style="color:#808080;">
                                                                            评论：<span style="color:#000;">${res.rows[i].content}</span>
                           </h5>
                       </div>
                       <div style="letter-spacing: 0px;line-height: 20px;word-break: break-all;">
                           <h5 class="fl" style="color:#808080;">
                                                                           评论时间：<span style="color:#000;">${res.rows[i].createTime}</span>
                           </h5>
                       </div>
                       <div class="divider2"></div>`);
                }
            }
        });
	})
	
	
	function gotoOrder(hospitalid,dutyDate){
		//检查是否登录
		var userid=getCookie("userid");
        if(userid==null||userid==''){
        	alert("未登录！");
        	window.location.href='login.html';
        }else{
        	var doctorid=$("#doctorid").val();
        	var data={'userid':userid,'doctorid':doctorid,"hospitalid":hospitalid,"looktime":dutyDate};
        	$.ajax({
        		type: "post",
                dataType: "json",
                data:JSON.stringify(data),
                contentType: "application/json; charset=utf-8",
                url: '/orders/insert',
                success:function(res){
                	alert("预约成功");
                	//location.reload();
                }
        	})
        }
	}
	
	function gotoComment(){
		//检查是否登录
        var userid=getCookie("userid");
        if(userid==null||userid==''){
            alert("未登录！");
            window.location.href='login.html';
        }else{
        	$("#userid").val(userid);
        	$('#myModal').on('hide.bs.modal');
            $('#myModal').modal('show')
        }
	}
</script>